// 清除large样式，导航的样式，banner文字的样式
function removeAllLarge(){
	var width =  $(window).width();
	if(width < 769){
		// 导航栏--在低于786下时，显示小的导航栏
		$('#header-nav').hide();
		
		$('.navi-toggle').addClass('page-wrap');
	} else {
		$('#header-nav').show();
		$('.navi-toggle').removeClass('page-wrap');
	}
}
function submitInfo(i) {
	var name = $('#name').val();
	var phone = $('#phone').val();
	var host = window.location.host;
	if(i==1) {
		name = $('#nav-name').val();
		phone = $('#nav-phone').val();
	}
	if(name == null || name == '') {
		$('#name').focus();
		return false;
	}
	if(phone == null || phone == '' ) {
		$('#phone').focus();
		return false;
	}
	 $.ajax({  
         type : "POST",  //提交方式  
         url : SERVER_PATH + "/user/v1/submitInfo?phoneNum="+phone+"&userName="+name+"&host="+host,//路径  
         success : function(result) {//返回数据根据结果进行相应的处理  
         	if(result.rescode == 100) {
         		alert("提交成功，请耐心等待咨询师与您联系");
         	} else {
         		alert(result.msg);
         	}
         }  
     });  
	
}
$(function(){
	removeAllLarge();
	// 右侧滑出菜单
	$('aside.slide-wrapper').on('touchstart', 'li', function(e) {
		$(this).addClass('current').siblings('li').removeClass('current');
	});

	$('.navi-toggle-btn').on('click', function(e) {
		var $menu = $('#navi-menu');
		var $right = $('#navi-menu-right').html();
		$menu.empty();
		$menu.append($right);
		var username = $('<li><input type="text" class="nav-input" placeholder="姓名" id="nav-name"/></li>');
		var phone = $('<li><input type="text" class="nav-input" placeholder="手机号" id="nav-phone"/></li>');
		var btn = $('<li><a id="nav-submit" onclick="submitInfo(1);"class="nav-sch-btn"  >提交</a></li>');
		
		$menu.append(username).append(phone).append(btn);
		var wh = $('div.wrapperhove' + 'rtree').height();
		$('div.slide-mask').css('height', wh).show();
		$('aside.slide-wrapper').css('height', wh).addClass('moved');
		
	});

	$('div.slide-mask').on('click', function() {
		$('div.slide-mask').hide();
		$('aside.slide-wrapper').removeClass('moved');
	});
});

$(window).resize(function() {
	removeAllLarge();
});

